<?php

/**
 * withdraw actions.
 *
 * @package    vmdai
 * @subpackage withdraw
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class withdrawActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
        $dql = Doctrine::getTable('UserAccountCashRecord')->createQuery()->orderBy('created_at desc');
        $page = $request->getParameter('page',1);
        $this->pager = new sfDoctrinePager('UserAccountCashRecord',21);
        $this->pager->setQuery($dql);
        $this->pager->setPage($page);
        $this->pager->init();
  }
  
  public function executeCheckwithdraw(sfWebRequest $request)
  {
            //修改用户提现记录
            $id=$request->getParameter("id");
            $user_id=$request->getParameter("uid");
            $user_cash_record = Doctrine::getTable('UserAccountCashRecord')->findOneById((int)$id);
            $user_cash_record->setStatus(1)->save();
            
            //修改提现锁定金额
            $current_money=$request->getParameter("current_money");
            $user_account = Doctrine::getTable('UserAccount')->findOneByUserId($user_id);
            $current_money=bcsub((int)$user_account->getDrawLocked(),(int)$current_money,sfConfig::get('app_value_bit'));
            $user_account->setDrawLocked($current_money)->save();
            $this->redirect('withdraw/index');
  }
}
